/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GUI;

import javax.microedition.lcdui.*;
import Model.*;

/**
 * фабрика классов ответвсвенных за отедельные этапы редактирования
 * @author Pisarchik_S
 */
public class Dispatcher {
    private CModel m_Model;
    private MoneyTracker m_MIDlet;

    private EMailSettings m_EmailSettings;

    Dispatcher(MoneyTracker midlet, CModel model)
    {
        m_MIDlet = midlet;
        m_Model = model;
        m_EmailSettings = new EMailSettings();
    }

    public Display GetDisplay()
    {
        return m_MIDlet.getDisplay();
    }

    public CreateNewRecord GetCreateNewDay()
    {
        return new CreateNewRecord(this, m_Model);
    }

    public ShowMonth GetShowMonth()
    {
        return new ShowMonth(this, m_Model);
    }

    public EditRecord GetEditRecord()
    {
        return new EditRecord(this, m_Model);
    }

    public MainMenuEditor GetMainMenuEditor()
    {
        return new MainMenuEditor(this);
    }

    public EditCategory GetEditCategory()
    {
        return new EditCategory(this, m_Model);
    }

    public ShowCategories GetShowCategories()
    {
        return new ShowCategories(this, m_Model);
    }

    public CreateNewCategory GetCreateNewCategory()
    {
        return new CreateNewCategory(this, m_Model);
    }

    public ShowStatistics GetShowStatistics()
    {
        return new ShowStatistics(this, m_Model);
    }

    public AskForThanks GetAskForThanks()
    {
        return new AskForThanks(this);
    }

    public EMailSettings GetEmailSettings()
    {
        return m_EmailSettings;
    }

    public EditEmailSettings GetEditEmailSettings()
    {
        return new EditEmailSettings(this, m_EmailSettings);
    }
    public About GetAbout()
    {
        return new About(this);
    }
    
    public void ClearAll()
    {
        m_Model.ClearAllRecords();
    }
    public void SaveAsFile()
    {
        new Thread(new Runnable(){
        public void run()
        {
        try{
            SaveToFile.DoSave(m_Model);
        }catch(Exception e){}
        }
        }).start();
    }

    public void SendEmail()
    {
        new Thread(new Runnable()
        {
            public void run()
            {
                try
                {
                    SendEmail se = new SendEmail(m_Model, m_EmailSettings);
                    se.Send();
                }
                catch(Exception e)
                {
                }
            }
        }).start();
    }

}
